package cn.itsource._02_work_queues;

import cn.itsource.ConnectionUtil;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

//发送消息
public class Send {

    public static final String NAME_WORK_QUEUES = "name_work_queue";

    public static void main(String[] args) throws Exception {
        //建立连接对象
        Connection connection = ConnectionUtil.getConnection();
        //建立通道
        Channel channel = connection.createChannel();
        //交换机使用默认的
        //声明队列
        channel.queueDeclare(NAME_WORK_QUEUES,true,false,false,null);
        //准备消息
        String message = "work queues message...";
        //发送消息
        channel.basicPublish("",NAME_WORK_QUEUES,null,message.getBytes());
        System.out.println("消息发送完毕"+message);

    }




}
